package controls.interaction
{
	import data.ClassGroup;
	import data.ClassSection;
	import data.Course;
	import data.FilterRange;
	
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;

	[Event(name="courseSelected", source="controls.interaction.InteractionEvent")]
	[Event(name="groupSelected", source="controls.interaction.InteractionEvent")]
	[Event(name="sectionSelected", source="controls.interaction.InteractionEvent")]
	[Event(name="updateFilter", source="controls.interaction.InteractionEvent")]
	
	public class InteractionCenter extends EventDispatcher
	{
		// --------------- Singleton Implementation ----------------- //
		private static var _instance:InteractionCenter;
		
		public static function get instance():InteractionCenter
		{
			if(_instance == null)
				_instance = new InteractionCenter();
			return _instance;
		}
		
		public function InteractionCenter(target:IEventDispatcher=null)
		{
			super(target);
			
			if(_instance != null)
				trace("Error: InteractionCenter is a singleton.");
				
			initComponents();
		}
		// --------------- END Singleton Implementation ----------------- //
		
		private function initComponents():void
		{
		}
		
		public function selectCourse(course:Course):void
		{
			this.dispatchEvent(new InteractionEvent(InteractionEvent.COURSE_SELECTED, course));
		}
		public function selectGroup(group:ClassGroup):void
		{
			this.dispatchEvent(new InteractionEvent(InteractionEvent.GROUP_SELECTED, group));
		}
		public function selectSection(section:ClassSection):void
		{
			this.dispatchEvent(new InteractionEvent(InteractionEvent.SECTION_SELECTED, section));
		}
		
		public function applyFilter(filter:FilterRange):void
		{
			this.dispatchEvent(new InteractionEvent(InteractionEvent.FILTER_UPDATE, filter));
		}
	}
}